package cn.zhaozhiqi.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.zhaozhiqi.constants.Constants;
import cn.zhaozhiqi.pojo.dto.AlipayNotifyDto;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.IPayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/pay")
public class AliPayController {

    @Autowired
    private IPayService payService;

    /**
     * 我们的业务逻辑处理完成之后，需要返回"success" 这7字符，如果返回"success"，那么支付宝不会通知你了
     * 如果返回其它任意字符串，那么支付宝还会尝试最大努力通知你 8
     * @param dto
     * @return
     */
    @Operation( summary= "支付宝支付的回调方法",description = "支付宝支付的回调方法接口")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/notify")
    @SaIgnore
    public JSONResult alipayNotify(@RequestBody AlipayNotifyDto dto){
        return JSONResult.success(payService.alipayNotify(dto));
    }
}
